package ru.rchervot.sanasar.client.event;

import com.google.gwt.event.shared.GwtEvent;

public class EventUIResultsSplitChange extends GwtEvent<HandlerUIResultsSplitChange> {
	private static Type<HandlerUIResultsSplitChange> TYPE = new Type<HandlerUIResultsSplitChange>();
	
	private final int splitPosition;
	
	public EventUIResultsSplitChange() {
		splitPosition = 0;
	} //TODO why not remove ?
	
	public EventUIResultsSplitChange(int splitPosition) {
		this.splitPosition = splitPosition;
	}
	
	@Override
	protected void dispatch(HandlerUIResultsSplitChange handler) {
		handler.onSplitChange(this);
	}

	/**
	 * Gets the type associated with this event.
	 * 
	 * @return returns the handler type
	 */
	public static Type<HandlerUIResultsSplitChange> getType() {
		if (TYPE == null) {
			TYPE = new Type<HandlerUIResultsSplitChange>();
		}
		return TYPE;
	}

	public Type<HandlerUIResultsSplitChange> getAssociatedType() {
		return TYPE;
	}

	public int getSplitPosition() {
		return splitPosition;
	}
	
	public static EventUIResultsSplitChange buildDefault() {
		return new EventUIResultsSplitChange(
				ru.rchervot.sanasar.client.view.Constants.RESULTS_SPLIT_POSITION);
	}
	
	public static EventUIResultsSplitChange buildExpandLeft() {
		return new EventUIResultsSplitChange(100);
	}

	public static EventUIResultsSplitChange buildExpandRight() {
		return new EventUIResultsSplitChange(0);
	}
}
